package com.parking.common.core.model;

import java.util.List;
import java.util.Set;

public class Result<T> {
    private String message;
    private Integer code;

    private Boolean flag;
    private T data;

    public static Result getResult(){
        Result result = new Result<String>();
        return result.setCode(200).setMessage("访问成功").setFlag(true);
    }
    public static <S> Result<S> getResult(Class<S> type){
        Result<S> result = new Result<S>();
        return result.setCode(200).setMessage("访问成功").setFlag(true);
    }
    public static <S> Result<List<S>> getListResult(Class<S> type){
        Result<List<S>> result = new Result<List<S>>();
        return result.setCode(200).setMessage("访问成功").setFlag(true);
    }
    public static <S> Result<Set<S>> getSetResult(Class<S> type){
        Result<Set<S>> result = new Result<Set<S>>();
        return result.setCode(200).setMessage("访问成功").setFlag(true);
    }

    public Integer getCode() {
        return code;
    }
    public Result<T> setCode(Integer code) {
        this.code = code;
        return this;
    }
    public String getMessage() {
        return message;
    }
    public Result<T> setMessage(String message) {
        this.message = message;
        return this;
    }
    public T getData() {
        return data;
    }
    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }
    public Boolean getFlag(){
        return flag;
    }
    public Result<T> setFlag(Boolean flag){
        this.flag = flag;
        return this;
    }
}
